<template>
  <div class="box">
    <div>
      <van-nav-bar
        title="客服"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
      />
    </div>

    <div class="kk" ref="kkk">
      <!-- <div>
        <img
          src="https://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/150/150-bigskin-7.jpg"
          style="
            height: 60px;
            width: 60px;
            border-radius: 50%;
            position: relative;
            right: -269px;
          "
        />
        <span
          style="
            background-color: aquamarine;
            display: inline-block;
            border-radius: 26px;
            position: relative;
            position: relative;
            right: -136px;
            bottom: 22px;
            line-height: 36px;
            text-indent: 21px;
            font-family: auto;
            width: auto;
            height: auto;
            margin-bottom: 10px;
          "
        >
          {{ sms }}
        </span>
      </div> -->
    </div>

    <div>
      <van-field
        class="mmm"
        v-model="sms"
        center
        clearable
        label="发送信息"
        placeholder="请输入要发送的信息"
      >
        <template #button>
          <van-button @click="send" size="small" type="primary"
            >发送</van-button
          >
        </template>
      </van-field>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  name: "KeFu",
  data() {
    return {
      sms: "哈哈哈",
    };
  },
  methods: {
    onClickLeft() {
      this.$router.back();
    },
    send() {
      // console.log(this.sms);

      let msl = `<div>
        <img
          src="https://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/150/150-bigskin-7.jpg"
          style="height: 60px; width: 60px; border-radius: 50%"
        />
        <span
          style="
            background-color: aquamarine;
            display: inline-block;
            border-radius: 26px;
            position: relative;
            left: 4px;
            top: -19px;
            line-height: 36px;
            text-indent: 21px;
            font-family: auto;
            width: auto;
            height: auto;
            margin-bottom: 10px;
          "
        >
          ${this.sms}
        </span>
      </div>`;

      let msr = `<div>
        <img
          src="https://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/150/150-bigskin-7.jpg"
          style="
            height: 60px;
            width: 60px;
            border-radius: 50%;
            position: relative;
            right: -269px;
          "
        />
        <span
          style="
            background-color: aquamarine;
            display: inline-block;
            border-radius: 26px;
            position: relative;
            position: relative;
            right: -136px;
            bottom: 22px;
            line-height: 36px;
            text-indent: 21px;
            font-family: auto;
            width: auto;
            height: auto;
            margin-bottom: 10px;
          "
        >
          ${ this.sms }
        </span>
      </div>
    </div>`;

      this.$refs.kkk.innerHTML += msl;

      this.$refs.kkk.scrollTop = this.$refs.kkk.scrollHeight;
      // console.log(this.$refs.kkk.scrollTo)

      // 发送完毕清除sms信息
      this.sms = "";
    },
  },
};
</script>

<style scoped>
.kk {
  height: 621px;
  margin: 10px;
  overflow: scroll;
  background-color: azure;
}

.mmm {
  display: flex;
  bottom: 6px;
}
</style>